package com.example.springboot.service.book;

import com.example.springboot.pojo.Book;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;


/**
 * 自动接收rabbitmq的消息并消费
 * @Author:ChenZhangKun
 * @Date: 2020/10/25 15:58
 */
@Service
public class BookService {
    @RabbitListener(queues = "czk.news")
    public void receive(Book book){
        System.out.println("收到消息");
    }
    @RabbitListener(queues = "czk")
    public void receive_02(Message message){
        System.out.println(message.getBody());
        System.out.println(message.getMessageProperties());
    }
}
